package com.youlu.campus.admin.vote.controller;

import com.alibaba.fastjson.JSON;
import com.youlu.campus.admin.vote.dto.OrgTypeSaveDTO;
import com.youlu.campus.admin.vote.dto.OrgTypeSearchDTO;
import com.youlu.campus.admin.vote.service.OrgTypeService;
import com.yuelin.infrastructure.quantum.common.QResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : [dengbo]
 * @className : OrganizationTypeController
 * @description : [组织类型]
 * @createTime : [2022/7/4 09:58]
 */
@Slf4j
@RestController
public class OrgTypeController {
    @Autowired
    private OrgTypeService orgTypeService;

    /**
     * 组织类型搜索
     * @param request
     * @return
     */
    @PostMapping("/org-type/search")
    public QResult search(@Validated @RequestBody OrgTypeSearchDTO request) {
        log.info("ActivityCourseController,list,request param:{}", JSON.toJSONString(request));
        return QResult.success(orgTypeService.list(request));
    }

    /**
     * 组织类型保存
     * @param request
     * @return
     */
    @PostMapping("/org-type/save")
    public QResult save(@Validated @RequestBody OrgTypeSaveDTO request) {
        log.info("ActivityCourseController,save,request param:{}", JSON.toJSONString(request));
        boolean re = orgTypeService.save(request);
        log.info("ActivityCourseController,save,response:{}", re);
        return QResult.success(re);
    }
}
